import request from '@/config/axios'

// ERP仓库管理-物料入库单主表 VO
export interface StockMaterialInboundVO {
  id: string // id
  inboundNo: string // 入库单号
  supplierId: string // 供应商id
  supplierCode: string // 供应商编号
  supplierName: string // 供应商名称
  warehouseId: string // 仓库id
  warehouseName: string // 仓库名称
  inboundDate: Date // 入库日期
  supplierOrderNo: string // 供应商单号
  monthlyPaymentDays: number // 月结天数
  audit: boolean // 审核
  auditor: string // 审核人
  auditTime: Date // 审核时间
  createVoucher: boolean // 创建凭证
  payableDueDate: Date // 应付截止日期
  discount: number // 折扣
  discountedAmount: number // 折扣后金额
  taxRate: number // 税率
  taxAmount: number // 税额
  remark: string // 备注
  totalAmount: number // 金额合计
  totalAmountWithTax: number // 总金额
  invoiceNo: string // 发票单号
  invoiceDate: Date // 发票时间
}

// ERP仓库管理-物料入库单主表 API
export const StockMaterialInboundApi = {
  // 查询ERP仓库管理-物料入库单主表分页
  getStockMaterialInboundPage: async (params: any) => {
    return await request.get({ url: `/erp/stock-material-inbound/page`, params })
  },

  // 查询ERP仓库管理-物料入库单主表详情
  getStockMaterialInbound: async (id: number) => {
    return await request.get({ url: `/erp/stock-material-inbound/get?id=` + id })
  },

  // 新增ERP仓库管理-物料入库单主表
  createStockMaterialInbound: async (data: StockMaterialInboundVO) => {
    return await request.post({ url: `/erp/stock-material-inbound/create`, data })
  },

  // 修改ERP仓库管理-物料入库单主表
  updateStockMaterialInbound: async (data: StockMaterialInboundVO) => {
    return await request.put({ url: `/erp/stock-material-inbound/update`, data })
  },

  // 删除ERP仓库管理-物料入库单主表
  deleteStockMaterialInbound: async (id: number) => {
    return await request.delete({ url: `/erp/stock-material-inbound/delete?id=` + id })
  },

  // 导出ERP仓库管理-物料入库单主表 Excel
  exportStockMaterialInbound: async (params) => {
    return await request.download({ url: `/erp/stock-material-inbound/export-excel`, params })
  },

// ==================== 子表（ERP仓库管理-物料入库单明细） ====================

  // 获得ERP仓库管理-物料入库单明细分页
  getStockMaterialInboundDetailPage: async (params) => {
    return await request.get({ url: `/erp/stock-material-inbound/stock-material-inbound-detail/page`, params })
  },
  // 新增ERP仓库管理-物料入库单明细
  createStockMaterialInboundDetail: async (data) => {
    return await request.post({ url: `/erp/stock-material-inbound/stock-material-inbound-detail/create`, data })
  },

  // 修改ERP仓库管理-物料入库单明细
  updateStockMaterialInboundDetail: async (data) => {
    return await request.put({ url: `/erp/stock-material-inbound/stock-material-inbound-detail/update`, data })
  },

  // 删除ERP仓库管理-物料入库单明细
  deleteStockMaterialInboundDetail: async (id: number) => {
    return await request.delete({ url: `/erp/stock-material-inbound/stock-material-inbound-detail/delete?id=` + id })
  },

  // 获得ERP仓库管理-物料入库单明细
  getStockMaterialInboundDetail: async (id: number) => {
    return await request.get({ url: `/erp/stock-material-inbound/stock-material-inbound-detail/get?id=` + id })
  }
}